package com.joelaws.prototype.client.service;

import com.google.gwt.ajaxsearch.client.ExpandMode;
import com.google.gwt.ajaxsearch.client.KeepLabel;
import com.google.gwt.ajaxsearch.client.LinkTarget;
import com.google.gwt.ajaxsearch.client.ResultSetSize;
import com.google.gwt.ajaxsearch.client.SearchControl;
import com.google.gwt.ajaxsearch.client.SearchControlOptions;
import com.google.gwt.ajaxsearch.client.WebSearch;
import com.gwtext.client.widgets.Panel;
import com.gwtext.client.widgets.layout.AnchorLayout;
import com.joelaws.prototype.client.data.User;

public class HomeTab extends Panel {

	// final private User thisUser;

	public HomeTab(User user) {
		// thisUser = user;

		setAutoScroll(true);
		setBorder(false);
		setFrame(true);
		setTitle("Home");
		setLayout(new AnchorLayout());

		add(getGoogleSearchPanel());
	}

	private Panel getGoogleSearchPanel() {
		final Panel panel = new Panel();
		panel.setLayout(new AnchorLayout());
		panel.setAutoScroll(true);
		panel.setBorder(false);
		panel.setFrame(false);

		SearchControlOptions options = new SearchControlOptions();
		WebSearch ws = new WebSearch();
		ws.setResultSetSize(ResultSetSize.SMALL);
		options.add(ws, ExpandMode.OPEN);
		options.setKeepLabel(KeepLabel.SAVE);
		options.setLinkTarget(LinkTarget.BLANK);

		panel.add(new SearchControl(options));

		return panel;

	}

}
